/**
 * 门诊简易挂号
 *
 * id 和李雨淋的保持一致，但是姓名的ID因为页面id冲突，改为gh_vaa05！！！！！！！！！！！！！
 */


	 var nianlianchusheng;
	 var nianlianjisuan;
	 var leibiefeibie=0;
	 var selectbcb01=0;
var simpaleIndex;
function guahao(that,issearch)
{
	$(that).attr("disabled",true);
	var mid = $("#minMenu").find(".checkMinMenu a").attr("id");
	var url = rootUrl + "/clidoctor/selectDataByScriptId?ID=7263";
	var para={};

	var url = rootUrl + "/clidoctor/selectDataByScriptId?ID=7263";
	var para={};
	var guhaoData,quanxianData;
	$.when(
			$.ajax(
				{
				type : 'get',
				url : rootUrl + "/clidoctor/selectDataByScriptId?ID=7263",
				dataType : "json",
				success : function(data)
				{
					guhaoData = data;
				}
			}),
	        $.ajax({
	            url: centerUrl + "/sysUser/initCloudUser",
	            type: "get",
	            dataType: "jsonp",
	            data: {
	                'userId': $.cookie('userId'),
	                'loginCode': $.cookie('loginName'),
	                'modId': mid
	            },
	            success: function (resp) {
	            	quanxianData = resp;
	            	}
	            })
	).done(function() {
		debugger;
		var data = $.extend(guhaoData,{"quanxian":quanxianData})
				if(data){
				laytplUrl(myurl + "/module/menzhen_guahao.html",data, function(data, html)
						{
					simpaleIndex = layer.open({
								type : 1,
								// scrollbar : false,
								title : "简易挂号",
								area :
									["75%", "70%"],
									shade : 0.1,
									maxmin : true,
									content : html,
									closeBtn : 1,
									zIndex :5000,
									success : function()
									{
										debugger;
										 //年龄日期单位事件绑定；
										ageChangeBind("vaa10","vaa12","aau01","vaa15");
										checkPermission(mid,".mid_title");
										$("#saveGuahao").find("select[id!='aau01']").select2({});
										guahaoinit();// 初始化input 和select
										hideAllDiv();
										gridxiangmu(-1,-1);//重新载入
										$("#mzserach").focus();
										$(that).removeAttr("disabled");
										//根据权限判断医生可以是否新增病人
										if($.inArray("jygh_onlysearch",authorityArr) >=0){ 
											disableEditPatientInfo();
									    }
										//键盘事件
										var  formId= "saveGuahao";
										var  classN="key_control_div";
										controlFromEvent(formId,classN);
										$(document).on('click', function(e) { 
											$("#vaa05html").hide();
									    });
										$(document).on('click', "#btn-grey_search", function(e) {
									   		var evt = e||window.event; evt.stopPropagation();
									   	});
										$(document).on('click', "#vaa05html", function(e) {
											var evt = e||window.event; evt.stopPropagation();
										});
										$(document).on('click', ".laypageskin_default", function(e) {
											var evt = e||window.event; evt.stopPropagation();
										});
										if(issearch == 's'){
											
											readAllCard();
										}
									},
									min: function (layero) {
						                var times = layero.attr('times');
						                $('#layui-layer-shade' + times).hide();
						            },
						            restore: function (layero) {
						                var times = layero.attr('times');
						                if ($('#layui-layer-shade' + times).css('display') == 'none') {
						                    $('#layui-layer-shade' + times).show();
						                }
						            },
							})

						});
				}
	})
}
function removeGuahao(){
	layer.close(simpaleIndex);
}
function guahaoinit()
{
	loadbcb03()
	loadiaa1(); //加载保险结构
	findInputEvent(); // input
	loadbdp02(); // 病人类别
	addaat02(); // 职业信息
	addack02(); // 婚姻状况
	addacc02(); // 国籍信息
	addabq02(); // 民族信息
	addabj02();// 医疗付款方式
	adduaa03(); // 获取社区
	addbdx02(); // 获取了解途径
	// addbah03(); //获取疾病分类
//	loadbcb01();//号类
//	addabu19();//获取住址
//	loadbaq01();//获取工作单位
	loadiar19();
//	loadSysParm();
}


/**
 * 加载险种名称
 */
function loadiar19(){
	var iax05="医疗保险参保类型";
	var url = rootUrl+"/clidoctor/selectDataByScriptId";
	var para = {
			ID:10000003,
			paramStr:'{iax05:"'+iax05+'"}'
			};
	$.when($.get(url, para)).done(function(json) {
		if(json.result=="Success"){
			$("#vaa19").find("option").remove();
			var option1= $("<option>").val("").text('请选择');
			$("#vaa19").append(option1);
			for (var i = 0; i < json.rows.length; i++) {
				var option = $("<option>").val(json.rows[i].vaa19).text(json.rows[i].vaa19).attr("id",json.rows[i].bdp02);
				$("#vaa19").append(option);
			}
		}
	})
}

function changeleibie()
{
	debugger;
	var bdp02 = $("#vaa19").find("option:selected").attr("id");
	if(bdp02){
		$("#bdp02").val(bdp02).trigger("change");
	}else{
		$("#bdp02").val("自费").trigger("change");
	}
}

/**
 * 加载挂号类别
 */
function loadbcb03(){
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
			{
			ID : 10000022,
			paramStr : '{CurrTime:"' + getcurrentDate() + '",DateNum:"' + getWeek() + '",ltime:"' + gettime() + '",Date:"' + getcurrDate() + '"}'
			}, function(json)
			{
				if (json.result == "Success")
				{
			$("#bcb03").find("option").remove();
			var option1= $("<option>").val(0).text('请选择');
			$("#bcb03").append(option1);
			for (var i = 0; i < json.rows.length; i++) {
				var option = $("<option data-id='"+JSON.stringify(json.rows[i])+"'>").val(json.rows[i].bcb01).text(
						json.rows[i].bcb03);
				$("#bcb03").append(option);
			}
			var bcb01_d = valueArr["p_100_105002_418"];
			$("#bcb03").val(bcb01_d).trigger("change");//默认普通号
		}
	});
}
//chang bcb03 关联赋值
function changbcb03(obj){
	//if(haoleiflag==true){
		var bcb01=$("#bcb03").val();
		var bcb03str = $("#bcb03").find("option:selected").attr("data-id");
		if(bcb03str){
			var bcbObj = JSON.parse(bcb03str);
			var bcb03=$("select[name=bcb03]").find("option:selected").text();
			$("#bcb01").val(bcb01);
			
			if (bcbObj.bao01==6)
			{
				$("#vac10_1").iCheck("check");
				$("#vac10").val(1);
			}
			else
			{
				$("#vac10_2").iCheck("check");
				$("#vac10").val(0);
			}
			
			gridxiangmu(bcb01,-1);
//		selectbcb01=bcb01;
//		loadbckdata(selectbcb01);
//		loadbcedata(selectbcb01);
			var boxes =document.getElementsByName('vac31');
			for(var i=0;i<boxes.length;i++){
				boxes[i].checked=false;
			}
			debugger;
			if($("#vaa03").val() == "" || $("#vaa03").val() == undefined){
				$("#vaa03")[0].value="";
				getvaa03();
			}
			//}
			
		}


}
/**
 * 加载保险结构
 */
function loadiaa1(){
	debugger;
	var url = rootUrl+"/clidoctor/selectDataByScriptId";
	var para = {
			ID:2251,
			paramStr:'{}'
			};
	$.when($.get(url, para)).done(function(json) {
		if(json.result=="Success"){
			var option1= $("<option>").val(0).text('请选择');
			$("#iaa01").empty().append(option1);
			for (var i = 0; i < json.rows.length; i++) {
				var option = $("<option>").val(json.rows[i].iaa01).text(json.rows[i].iaa03);
				$("#iaa01").append(option);
			}
		}
	})

}
/**
 * 加载医疗类别
 */
function loadiai1(obj){
	debugger;
	$("#iai01").find("option").remove();
	var iaa01=$("#iaa01").val();
	if(obj !=undefined){
		iaa01=$(obj).val();
	}
	var url = rootUrl+"/clidoctor/selectDataByScriptId";
	var para = {
			ID:2254,
			paramStr:'{IAA01:'+iaa01+',ACF01=1}'
			};
	$.when($.get(url, para)).done(function(json) {
		if(json.result=="Success"){
			$("#iai01").find("option").remove();
	/*		var option1= $("<option>").val(0).text('请选择');
			$("#iai01").append(option1);*/
			for (var i = 0; i < json.rows.length; i++) {
				var option = $("<option>").val(json.rows[i].iai01).text(
						json.rows[i].iai04+"("+json.rows[i].iai03+")");
				$("#iai01").append(option);
			}

			//加载默认值
			$("#iai01").find("option[value='19']").attr("selected",true).trigger("change");
		}
	})

}
/*
 * 加载病人类别
 */
function loadbdp02()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 4169,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#bdp02").empty();
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].bdp02).text(json.list[i].bdp02);
				$("#bdp02").append(option);
			}
			loadabc02($("#bdp02"));
		}
	});
}
// 获取职业的信息
function addaat02()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 616,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#vac16").empty();
			var option = $("<option>").val(0).text("--请选择--");
			$("#vac16").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].aat01).text(json.list[i].aat02);
				$("#vac16").append(option);
			}
		}
	});
}
// 获取婚姻的信息
function addack02()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 593,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#ack01").empty();
			var option = $("<option>").val(0).text("--请选择--");
			$("#ack01").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].ack01).text(json.list[i].ack02);
				$("#ack01").append(option);
			}
		}
	});
}

// 获取国籍的信息
function addacc02()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 549,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#acc02").empty();
			var option = $("<option>").val(0).text("--请选择--");
			$("#acc02").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].acc02).text(json.list[i].acc02);
				$("#acc02").append(option);
			}
		}
	});
}
// 获取民族的信息
function addabq02()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 39,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#abq02").empty();
//			var option = $("<option>").val('汉族').text("--请选择--");
//			$("#abq02").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].abq02).text(json.list[i].abq02);
				$("#abq02").append(option);
			}
			$("#abq02").val('汉族');
		}
	});
}
// 获取医疗付款方式
function addabj02()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 553,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#abj01").empty();
			var option = $("<option>").val(0).text("--请选择--");
			$("#abj01").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].abj01).text(json.list[i].abj02);
				$("#abj01").append(option);

			}
		}
	});
}
// 获取社区
function adduaa03()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 2001,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#uaa01").empty();
			var option = $("<option>").val(0).text("--请选择--");
			$("#uaa01").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].uaa01).text(json.list[i].uaa03);
				$("#uaa01").append(option);
			}
		}
	});

}
// 获取了解途径
function addbdx02()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 617,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#bdx02").empty();
			var option = $("<option>").val(0).text("--请选择--");
			$("#bdx02").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].bdx02).text(json.list[i].bdx02);
				$("#bdx02").append(option);

			}
		}
	});
}
// 获取疾病分类
function addbah03()
{
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 5250,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
			$("#bah03").empty();
			var option = $("<option>").val(0).text("--请选择--");
			$("#bah03").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
				var option = $("<option>").val(json.list[i].bah03).text(json.list[i].bah03);
				$("#bah03").append(option);
			}
		}
	});
}
// 加载挂号挂别的信息
function loadbcb01()
{
	var bcb01td;
	$("#bcb03").on('click', function()
			{

				var bce03flag = false;
				$("#bcb03").val("");
				$('#bck03').val("");
				$('#bce03').val("");
				var selectleft = $(this).parent().parent().position().left;
				var selecttop = $(this).parent().parent().position().top;
				$.get(rootUrl + "/clidoctor/selectDataByScriptId",
						{
						ID : 1878,
						paramStr : '{CurrTime:"' + getcurrentDate() + '",DateNum:"' + getWeek() + '",ltime:"' + gettime() + '",Date:"' + getcurrDate() + '"}'
						}, function(json)
						{
							if (json.result == "Success")
							{
								$("#layercover").removeClass("hidden");
								$("#bcb01html").css(
								{
								left : selectleft + 'px',
								top : selecttop + 30 + 'px'
								}).slideDown(300);
								$('#bcb01html').find("tbody tr").remove();
								bcb01td = "";
								for (var i = 0; i < json.list.length; i++)
								{
									var bcb01 = json.list[i].bcb01;
									if (bcb01 == undefined)
										bcb01 = "";
									var bcb03 = json.list[i].bcb03;
									if (bcb03 == undefined)
										bcb03 = "";
									var bao02 = json.list[i].bao02;
									if (bao02 == undefined)
										bao02 = "";
									var bck03 = json.list[i].bck03;
									if (bck03 == undefined)
										bck03 = "";
									var bce03 = json.list[i].bce03;
									if (bce03 == undefined)
										bce03 = "";
									var bby05 = json.list[i].bby05;
									if (bby05 == undefined)
										bby05 = "";
									bcb01td += "<tr>" + "<td  hidden='true'>" + bcb01 + "</td>" + "<td>" + bcb03 + "</td>" + "<td>" + bao02 + "</td>" + "<td>" + bck03 + "</td>" + "<td>" + bce03 + "</td>" + "<td>" + bby05 + "</td>" + "<td  hidden='true'>" + json.list[i].bce01 + "</td>" + "<td hidden='true'>" + json.list[i].bck01 + "</td>" + "</tr>";
								}
							}
							$('#bcb01html tbody').append(bcb01td);
							$('#bcb01html tbody tr').on('click', function()
							{
								$("#bcb01").val($(this).find("td").eq(0).html());
								$("#bcb03").val($(this).find("td").eq(1).html());
								$('#bck03').val($(this).find("td").eq(3).html());
								$('#bce03').val($(this).find("td").eq(4).html());
								$('#bck01').val($(this).find("td").eq(7).html());
								$("#bce01").val($(this).find("td").eq(6).html());
								gridxiangmu($(this).find("td").eq(0).html(), -1);
								selectbcb01 = $(this).find("td").eq(0).html();
								$.get(rootUrl + "/clidoctor/selectDataByScriptId",
								{
								ID : 5253,
								paramStr : '{BCB01:' + selectbcb01 + '}'
								}, function(json)
								{
									if (json.result == "Success")
									{
										if (json.list.length > 0)
										{
											$('#bck03').val(json.list[0].bck03);
											$('#bck01').val(json.list[0].bck01);
											loadbck03(selectbcb01);
											bce03flag = true;
										}
										else
										{

											loadbck01();
										}
									}
								});
								var boxes = document.getElementsByName('vac31');
								for (var i = 0; i < boxes.length; i++)
								{
									boxes[i].checked = false;
								}
								$(".selectTab").slideUp(300);
								$("#layercover").addClass("hidden");
								if (!$("#vaa03_1").val())
								{
									$("#vaa03")[0].value = "";
									getvaa03();
								}
							})
						});

			})

}
//加载费用项目的数据
function  gridxiangmu(bcb01,vac31){
	$('#xiangmu_info_content').resize(function(){
		$("#xiangmu_info_table").setGridWidth($("#xiangmu_info_content").width()*1);
	});
	jQuery('#xiangmu_info_table').GridUnload();
	jQuery("#xiangmu_info_table").jqGrid(
	          {
	        	url : rootUrl + "/clidoctor/commonQuery",
	        	postData:{ID : 1880,paramStr : "{BBY31:" + ShowMessage() + ",BCB01:" + bcb01 + "}"},
	            datatype : "json",
	            colNames:['选择','项目','金额','费目','bby01','bcf01','selected1'],
	            colModel:[ //这一项比较重要， 其中的name属性主要是用于后期的页面代码（注意这里的范围是本页面上的代码，不会涉及到后台代码）， 而index属性是则是用于涉及后台时，给后台传递排序字段
	                   {name:'selected',index:'selected',width:60,align:'center',edittype:'checkbox',formatter:
	                	   function(v,x,r){
		                	   if(r.bcf01 ==1){
		                   		   return "<input type='checkbox' checked='true' onchange='changeselect(this,"+x.rowId+");'/>";
		                   	   }else{
		                   		   return "<input type='checkbox'  onchange='changeselect(this,"+x.rowId+");'/>";
		                   	   }
	                	   }
	                   },
	                   {name:'bby05',index:'bby05',editable:true}, //sortable是该字段是否排序      //colModel两个最主要就是1:name前台js用,2:index给后台传递排序字段
	                   {name:'bby25',index:'bby25',editable:true},
	                   {name:'bcf03',index:'bcf03',editable:true},
	                   {name:'bby01',index:'bby01',editable:true,hidden:true},
	                   {name:'bcf01',index:'bcf01',editable:true,hidden:true},
	                   {name:'selected1',index:'selected1',editable:true,hidden:true,formatter:
	                	  function(v,x,r){
	                	   if(v==undefined || v==1){
	                   		   return 1;
	                   	   }else{
	                   		   return 0;
	                   	   }
                	   }}
	                   ],
	                   multiselect: false,
	                   height : 'auto',
		       			width : '100%',
		       			autowidth : true,
		       			forceFit:true,
		       		    shrinkToFit:true,
	                   rownumbers:true,
	                   gridComplete : function() {
	                	   if(bcb01==-1 && vac31==-1)
	                		{
	                			$("#xiangmu_info_table").clearGridData().setGridParam({data:[],}).trigger("reloadGrid");
	                		}
	                		else
	                		{
	                			jQuery("#xiangmu_info_table").jqGrid('setGridParam',{
	                		           url : rootUrl + "/clidoctor/commonQuery",
	                		           datatype : 'json',
	                		           //发送数据
	                		           postData:{ID : 1880,paramStr : "{BBY31:" + ShowMessage() + ",BCB01:" + bcb01 + "}"},
	                		           page : 1,
	                		           rownumbers:true
	                		        }).trigger('reloadGrid');//重新载入
	                		}
	                     },


	          }

	      )
	}
function ShowMessage()

{
	var today = new Date();
	var day = today.getDate();
	//获取当前日
	var month = today.getMonth() + 1;
	//显示月份比实际月份小
	var year = today.getFullYear();
	//获取完整的年份
	month = month < 10 ? "0" + month : month;
	//数字
	day = day < 10 ? "0" + day : day;
	var date = year + "-" + month + "-" + day;

	return date;

}
function getcurrentDate()

{
	var today = new Date();
	var day = today.getDate();
	// 获取当前日
	var month = today.getMonth() + 1;
	// 显示月份比实际月份小
	var year = today.getFullYear();
	var hour = today.getHours();
	var minute = today.getMinutes();
	var second = today.getSeconds();

	// 获取完整的年份
	hour = hour < 10 ? "0" + hour : hour;
	minute = minute < 10 ? "0" + minute : minute;
	month = hour < 10 ? "0" + month : month;
	second = second < 10 ? "0" + second : second;
	// 数字
	day = day < 10 ? "0" + day : day;
	var date = year + "-" + month + "-" + day + " " + hour + "^" + minute + "^" + second;

	return date;

}
function getWeek()

{
	var today = new Date();
	var day = today.getDay();

	return day + 1;

}
function gettime()
{
	var today = new Date();
	var h = today.getHours(); // 获取系统时
	if (h < 10)
	{
		h = "0" + h;
	}
	var m = today.getMinutes(); // 分
	if (m < 10)
	{
		m = "0" + m;
	}
	var s = today.getSeconds(); // 秒
	if (s < 10)
	{
		s = "0" + s;
	}
	var mytime = h + "^" + m + "^" + s;
	return mytime;
}
function getcurrDate()

{
	var today = new Date();
	var day = today.getDate();
	// 获取当前日
	var month = today.getMonth() + 1;
	// 显示月份比实际月份小
	var year = today.getFullYear();
	// 获取完整的年份

	month = month < 10 ? "0" + month : month;

	// 数字
	day = day < 10 ? "0" + day : day;
	var date = year + "-" + month + "-" + day + " " + "00" + "^" + "00" + "^" + "00.000";

	return date;

}
//获取门诊号
function getvaa03(){
	var url=rootUrl + "/clidoctor/getvaa03";
	  $.ajax({
          url:url,
          type:"get",
          dataType:"json",
          async: false,
          cache:false,
          success:function(json){
        	  if(json.result=="SUCCESS"){
        		$("#vaa03_1").val(json.list[0].VAA03);
      			$("#vaa03").val(json.list[0].VAA03);
      		}
          }
      });
}

//加载科室信息

function loadbck03(bcb01){
	if(selectbcb01!= bcb01)return;
	var bck03td;
	var flag=true;
	$("#bck03").on('click',function(){
		if(selectbcb01!= bcb01){
			loadbck01();
			return;
		}
		$('#bck03html').find("tbody tr").remove();
		var selectleft=$(this).offset().left-210;
		var selecttop=$(this).offset().top-118;
		$.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:5253,paramStr:'{BCB01:'+ selectbcb01 + '}'}, function(json){
			if(json.result=="Success"){
				$('#bck03html table').css("width","100%");
				$("#bck03html").css({left:selectleft+'px',top:selecttop+30+'px'}).slideDown(300);
				$('#bck03html').find("tbody tr").remove();
				 bck03td = "";
					 for(var i=0;i<json.rows.length;i++){
						    var bck02=json.rows[i].bck02;
						    if(bck02==undefined) bck02="";
						    var bck03=json.rows[i].bck03;
						    if(bck03==undefined) bck03="";
						    bck03td +="<tr>"+
							"<td>"+bck02+"</td>"+
							"<td>"+bck03+"</td>"+
							"<td  hidden='true'>"+json.rows[i].bck01+"</td>"+
							"</tr>";
						}
					}
				 $('#bck03html tbody').append(bck03td);
				 $('#bck03html tbody tr').on('click',function(){
						$('#bck03').val($(this).find("td").eq(1).html());
						$('#bck01').val($(this).find("td").eq(2).html());

			    	})
		});

	})
	 $.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:5254,paramStr:'{BCB01:'+ bcb01 + '}'}, function(json){
			if(json.result=="Success"){
				if(json.rows.length>0){
						$('#bce03').val(json.rows[0].bce03);
						$('#bce01').val(json.rows[0].bce01);
						if(selectbcb01 == bcb01){
						   loadbce03(selectbcb01);
						}
				}
			}
		});
}

var bck01bce01;
function loadbck01(obj){
	var bck03td;
	$("#bck03").val("");
	$("#bck03").on('click',function(){
		if(bce03flag==true){
			loadbck03(selectbcb01);
			return;
		}
		$('#bck03html').find("tbody tr").remove();
		var selectleft=$(this).offset().left-210;
		var selecttop=$(this).offset().top-118;
		ajaxGet(hostUrl+"/his/common/querylectDataByScriptId",{ID:451,paramStr:''}, function(json){
			if(json.result=="Success"){
				$('#bck03html table').css("width","150%");
				$("#bck03html").css({left:selectleft+'px',top:selecttop+30+'px'}).slideDown(300);
				$('#bck03html').find("tbody tr").remove();
				bck03td="";
				   for(var i=0;i<json.rows.length;i++){
					    var bck02=json.rows[i].bck02;
					    if(bck02==undefined) bck02="";
					    var bck03=json.rows[i].bck03;
					    if(bck03==undefined) bck03="";
					    bck03td +="<tr>"+
						"<td>"+bck03+"</td>"+
						"<td>"+bck02+"</td>"+
						"<td  hidden='true'>"+json.rows[i].bck01+"</td>"+
						"</tr>";
					}
				}
				$('#bck03html tbody').append(bck03td);
				$('#bck03html tbody tr').on('click',function(){
					$('#bck03').val($(this).find("td").eq(0).html());
					$('#bck01').val($(this).find("td").eq(2).html());
					bck01bce01=$(this).find("td").eq(2).html();
					loadbce01(bck01bce01);
				    $('#bck03html').slideUp();
		    	})
		});

	})

}

function loadbce03(bcb01){

	if(selectbcb01!= bcb01)return;
	var bce03td;
	$("#bce03").on('click',function(){
		if(selectbcb01!= bcb01){
			loadbce01();
			return;
		}
		$('#bce03html').find("tbody tr").remove();
		var selectleft=$(this).offset().left-210;
		var selecttop=$(this).offset().top-118;
		$.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:5254,paramStr:'{BCB01:'+ selectbcb01 + '}'}, function(json){
			if(json.result=="Success"){
				$('#bce03html table').css("width","100%");
				$("#bce03html").css({left:selectleft+'px',top:selecttop+30+'px'}).slideDown(300);
				bce03td="";
				 $('#bce03html').find("tbody tr").remove();
				   for(var i=0;i<json.rows.length;i++){
					    var bce02=json.rows[i].bce02;
					    if(bce02==undefined) bce02="";
					    var bce03=json.rows[i].bce03;
					    if(bce03==undefined) bce03="";
					    var bce04=json.rows[i].bce04;
					    if(bce04==undefined) bce04="";
					    var aah02=json.rows[i].aah02;
					    if(aah02==undefined) aah02="";
					    bce03td +="<tr>"+
						"<td>"+bce02+"</td>"+
						"<td>"+bce03+"</td>"+
						"<td>"+bce04+"</td>"+
						"<td>"+aah02+"</td>"+
						"<td  hidden='true'>"+json.rows[i].bce01+"</td>"+
						"</tr>";
					}
				}
				$('#bce03html tbody').append(bce03td);
				$('#bce03html tbody tr').on('click',function(){
				$('#bce03').val($(this).find("td").eq(1).html());
				$('#bce01').val($(this).find("td").eq(4).html());
		    	})
		});

	})

}
//加载费别的信息
function loadabc02(obj){
	debugger;
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:5240,paramStr:'{BDP02:"'+$(obj).find("option:selected").text()+'"}'}, function(json){
		debugger;
		if(json.result=="Success"){
//			for(var i=0;i<json.rows.length;i++){
				$("#gh_abc02").val(json.rows[0].abc02);
//			}
		}
	});
}

//复诊赋值
function checkvac06(obj) {
	if ($(obj).html()=="是") {
		$("#vac06_1").removeClass("btn-white").addClass("btn-grey");
		$("#vac06_2").removeClass("btn-grey").addClass("btn-white");
		$("#vac06").val(1);
	} else {
		$("#vac06_1").removeClass("btn-grey").addClass("btn-white");
		$("#vac06_2").removeClass("btn-white").addClass("btn-grey");
		$("#vac06").val(0);
	}

}
//急诊赋值
function checkvac10(obj) {
	if ($(obj).html()=="是") {
		$("#vac10_1").removeClass("btn-white").addClass("btn-grey");
		$("#vac10_2").removeClass("btn-grey").addClass("btn-white");
		$("#vac10").val(1);
	} else {
		$("#vac10_1").removeClass("btn-grey").addClass("btn-white");
		$("#vac10_2").removeClass("btn-white").addClass("btn-grey");
		$("#vac10").val(0);
	}
}
//是否查看健康档案赋值
function checkvcj15(obj) {
	if ($(obj).html()=="是") {
		$("#vcj15_1").removeClass("btn-white").addClass("btn-grey");
		$("#vcj15_2").removeClass("btn-grey").addClass("btn-white");
		$("#vcj15").val(1);
	} else {
		$("#vcj15_1").removeClass("btn-grey").addClass("btn-white");
		$("#vcj15_2").removeClass("btn-white").addClass("btn-grey");
		$("#vcj15").val(0);
	}
}

/**
 * 保存挂号信息
 */
var grid2rows;
var mydata;
 function saveGuahao(that)
 {
	 totalVbi = 0.0; // 挂号产生的费用
	 $(that).attr("disabled",true);
	 $(that).removeClass("btn-green");
	 layer.msg('保存中....', {icon: 16,shade: [0.1, '#393D49'],time:1*500,skin: 'layui-layer-msg16'});
	 debugger;
	 var n = /^[0-9]*[1-9][0-9]*$/;// 正整数；
	 var url = rootUrl + "/cliregistration/save_charge";
	 //挂号数据
	 var bck01Obj = {name:"lBCK01",value:$("#departmentList").find("option:selected").attr("id")};
	 var vac45Obj = {name:"lVAC45",value:1};
	 var bce01Obj = {name:"lBCE01",value:bce01};
	 var bce02Obj = {name:"lBCE02A",value:loginName};
	 var bce03Obj = {name:"lBCE03A",value:bce03};
	 var bcb03a = {name:"lBCB03A",value:$("#bcb03").find("option:selected").text()};
	 var data1 = $("#saveGuahao").serializeArray();
	 data1.push(bck01Obj);
	 data1.push(vac45Obj);
	 data1.push(bce01Obj);
	 data1.push(bce02Obj);
	 data1.push(bce03Obj);
	 data1.push(bcb03a);
	 console.log(data1);
	 var arr = [];
	var allMust = $(".all_content").find(".key_control_div:visible").find(".must").filter(":contains('*')");
	allMust.each(function(i,e){
		var curobj = {}
		var cur = $(e).parents(".key_control_div").find("select").length>0?$(e).parents(".key_control_div").find("select"):$(e).parents(".key_control_div").find("input[type='text']");
		if(cur.length <1){
			i++;
		}else{

			if(!($(cur).val())){
				var thismsg =  $(e).parents(".key_control_div").find(".name").text().trim();
				var thisid= $(e).parents(".key_control_div").find("select").length>0?$(e).parents(".key_control_div").find("select").attr("id"):$(e).parents(".key_control_div").find("input[type='text']").attr("id");
				bcb03.msg ="";
				curobj.id = thisid;
				curobj.thismsg = thismsg;
				arr.push(curobj);
			}
		}
	});

	var tipFlag = false;
	$(arr).each(function(i,ele){
		if(!ele.value){
			layer.tips(ele.thismsg+"不能为空", '#'+ele.id, {
				  tipsMore: true
			});
			tipFlag = true;
		}
	})
	if(tipFlag){
		 $(that).removeAttr("disabled");
		  $(that).addClass("btn-green");
		return false;
	}
	if (!n.test($("#vaa10").val())){
		 $(that).removeAttr("disabled");
		  $(that).addClass("btn-green");
		layer.tips('请输入正确的年龄', '#vaa10', {
			  tips: [1, '#e44c3e'] //还可配置颜色
			});
		return;
	}
	var resultA= [];
	 for(var k=0;k<data1.length;k++){
		 if(data1[k].value){
			 resultA.push(data1[k]);
		 }
	 }
	 //处理不可编辑的数据文本
	 if($.inArray("jygh_brxx",authorityArr)!= -1){ 
		 resultA = disableData(resultA);
		 
	 }
	 //费用数据
//	 var grid2 = $("#xiangmu_info_table").jqGrid("getRowData");
	 var grid2 = []; //选中的数据
	 var checkTr  = $("#xiangmu_info_table tbody").find("input:checked");

	 for(var i = 0;i<checkTr.length;i++){
		 var id = $(checkTr[i]).parents("tr").attr("id");
		 grid2.push($("#xiangmu_info_table").jqGrid("getRowData", id))
	 }
	 for(var i = 0;i<grid2.length;i++)
	 {
		 var vaj1 = {};
		 vaj1.acf01 = 1;
		 vaj1.bce01 = bce01;//操作员id
		 vaj1.bck01 = $("#departmentList").find("option:selected").attr("id");//科室id
		 vaj1.bce02 = bce03;//操作员姓名
		 vaj1.vaj38 = parseFloat(grid2[i].bby25);//基本账户扣费
		 vaj1.AType = 0;// 0 = 扣费,1 = 退费
		 vaj1.AWorkType = 8;// 门诊记账
		 vajList.push(vaj1);

		 grid2[i].vaj25 = 1;
		 grid2[i].vaj30 = 100;
		 grid2[i].vaj31 = 100;
		 grid2[i].vaj33 = grid2[i].bby25;
		 grid2[i].vaj36 = grid2[i].bby25;
		 grid2[i].vaj37 = grid2[i].bby25;
		 totalVbi+=parseFloat(grid2[i].bby25);
	 }

	 grid2rows = JSON.stringify(grid2);
	 for(var i = 0;i<resultA.length;i++)
	 {
		 //地址
		 var temp = resultA[i];
		 if(temp.name=="lVAA33")
		 {
			 resultA.push({name:"lVAC19",value:temp.value});
		 }
		 //电话
		 if(temp.name=="lVAA35")
		 {
			 resultA.push({name:"lVAC20",value:temp.value});
		 }
		 //人名去空格
		 if(temp.name=="lVAA05")
		 {
			 resultA[i].value = resultA[i].value.trim();
		 }
		 
	 }
	 mydata = JSON.stringify(resultA);
	 if(valueArr['p_9999_9999_113']=='1')
	 {
		 saveGuhaoCharge();
		 $(that).removeAttr("disabled");
		  $(that).addClass("btn-green");
	 }
	 else
	 {
		 $.ajax({url:url,
			 data:{"mydata":mydata,"grid2rows":grid2rows},
			 type:"post",
			 dataType:"json",
			 success:function(data){
				 debugger;
				 if(data.result=="Success")
				 {
					 layer.msg("保存成功",{icon:1,skin: 'layui-layer-msg1',time:2000});
					 layer.closeAll();
					 hujiao_(data.userdata);
//					 refreshListHouzhen();
				 }
				 else
				 {
					 layer.alert(data.resultMsg?data.resultMsg:"保存失败",{icon:0});
					 $(that).removeAttr("disabled");
					  $(that).addClass("btn-green");
				 }
		 }});
	 }

 }

 function disableData(resultA){
	 $("#saveGuahao  .ifEditItem").each(function(e,ele){
			var name = $(ele).attr("name");
			var key =  $(ele).val();
			var obj = {};
			obj.name = name;
			obj.value = key;
			resultA.push(obj);
		})
		return resultA; 
 }

 /**
  * 刷卡交易
  */
 function skjy()
 {
	 layer.closeAll();
		var guahaoVajList = [];
		//判断余额是可以扣费
		var isPay = 0;
		if(parseFloat(cardMap.vbu14)>=parseFloat(totalVbi)){
			isPay = 1;
		}
		for (var int = 0; int < vajList.length; int++)
		{
			var vaj = vajList[int];
			var params = {};
			params.ACF01 = vaj.acf01;
			params.BCE01 = vaj.bce03a;//操作员id
			params.BCK01 = vaj.bck01b;//科室id
			params.BCE02 = vaj.bce02b;//操作员code
			params.BCE02 = vaj.bce03a;//操作员姓名
			params.VAJ38 = vaj.vaj38;//基本账户扣费
			params.AType = 0;//0 = 扣费,1 = 退费
			params.AWorkType = 8;//简易挂号
			guahaoVajList.push(params);
		}
			var postData = {};
			postData.chargejson = JSON.stringify(guahaoVajList);
			postData.grid2rows = grid2rows;
			postData.mydata = mydata;
			postData.isPay = isPay;
			$.ajax
			({
				url:rootUrl + "/cliregistration/save_charge",//调用rest
				type:"post",
				dataType:"json",
				data:postData,
				success:function(data)
				{
					var vipId = $("#vipId").text();
					if(data && data.result.toLowerCase()=="success")
					{
						layer.closeAll();
						 hujiao_(data.userdata);
						if(isPay==1){
							layer.msg("已成功扣费"+totalVbi+"元",{icon:1,time:5000,skin: 'layui-layer-msg1'});
						}else{
							layer.msg("挂号成功！",{icon:1,time:4000,skin: 'layui-layer-msg1'});
						}
					}
					else
					{
						layer.alert(data.resultMsg,{icon:2,title:"警告"});
					}
					totalVbi = 0;
				}
			});
	 
 }
 //加载公共参数
   function loadcommonsettingvalue(){
   	$.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:16780,paramStr:'{ProductID:9999,ProgramID:9999,UserID:'+$.cookie('userId')+',BCKID:1,hostid:156}'}, function(json){
   		if(json.result=="Success"){
   			for(var i=0;i<json.rows.length;i++){
   				if(json.rows[i].paramno==58){
   					 nianlianjisuan=json.rows[i].value;
   				}else if(json.rows[i].paramno==18){
   					leibiefeibie=json.rows[i].value;

   				}
   		     }
   	       }
     });
   	return leibiefeibie;
   }

   /**
    * 计算月龄
    *
    */
    function monthDef(birthDayDate,nowDate){
        var intBeginYear = parseInt(birthDayDate.substring(0, 4));
           //从"-"后截取月数
    var intBeginMonth = parseInt(birthDayDate.substring(birthDayDate.indexOf("-") + 1, birthDayDate.indexOf("-") + 3),10);
       var intBeginDate = parseInt(birthDayDate.substring(birthDayDate.lastIndexOf("-") + 1, birthDayDate.lastIndexOf("-") + 3),10);

      var intEndYear = parseInt(nowDate.substring(0, 4));
      var intEndMonth = parseInt(nowDate.substring(nowDate.indexOf("-") + 1, nowDate.indexOf("-") + 3),10);
        var intEndDate = parseInt(nowDate.substring(nowDate.lastIndexOf("-") + 1, nowDate.lastIndexOf("-") + 3),10);

       var year = (intEndYear - intBeginYear) * 12;
       var month = intEndMonth - intBeginMonth;
        var result = year + month - 1;
       if(intEndDate - intBeginDate < 0 && getMonthMaxDay(intBeginYear, intBeginMonth) - intBeginDate + intEndDate >= 15){
    	   if(nianlianjisuan=="1" && (intBeginMonth>intEndMonth || (intBeginMonth==intEndMonth && intBeginDate>intEndDate))){
    		   result = year + month - 1;
               result = result;
    	   }else{
    		   result = year + month - 1;
               result = result + 1;
    	 }

            }else if(intEndDate - intBeginDate < 0 &&getMonthMaxDay(intBeginYear, intBeginMonth) - intBeginDate + intEndDate < 15){
               result = year + month - 1;
              result = result;
          }else if(intEndDate - intBeginDate > 0 &&intEndDate - intBeginDate  >= 15){
              result = year + month;
               result = result + 1;
           }else if(intEndDate - intBeginDate > 0 &&intEndDate - intBeginDate  < 15){
               result = year + month;
               result = result;
               if(result==0){
            	   $("#vaa10").val(intEndDate-intBeginDate);
            	   $("#aau01").val("D");
               }
           }
            if(result ==undefined ){
                result = 0;
          }
          return result;
   }
    /*------------------------------------------------------检索-------------------------------------------------------*/

  //据据门诊号、姓名、五笔、拼音、身份证等进行检索病人信息
    var rownumbr=10;
  function searchData(page,e,obj) {
	if($("#vaa05html").is(":visible")){
		$("#vaa05html").slideUp(200);
		$("#layercover").addClass("hidden");
	}else{
		$("#vaa05table").find("tr").removeClass("checkedTr");
		var isCheckedTr=$("#vaa05table").find("tr").hasClass("checkedTr");
		if ((e.keyCode == 13 || e==undefined || e.keyCode==undefined)) {
			if(obj != undefined){
				obj.blur();
			}
			var searchKey = $("#searchKey").val();
			var paramKey;
			if (searchKey == "a.VAA03") {
				paramKey = "VAA03";
			} else if (searchKey == "a.VAA05") {
				paramKey = "VAA05";
			} else if (searchKey == "a.ABBRP") {
				paramKey = "ABBRP";
			} else if (searchKey == "a.VAA15") {
				paramKey = "VAA15";
			} else if (searchKey == "a.VAA02") {
				paramKey = "VAA02";
			} else if (searchKey == "a.VAA35") {
				paramKey = "VAA35";
			} else if (searchKey == "a.VAA84") {
				paramKey = "VAA84";
			}
			debugger;
			var selectleft=$("#mzserach").position().left;
			var selecttop=$("#mzserach").position().top;
			$("#vaa05html").css({left:selectleft+'px',top:selecttop+30+'px'}).slideDown(200);
			getSearchData(paramKey,page);

		}
		return false;
	}
  }
  function getSearchData(paramKey,page){
	  var mzserach=$("#mzserach").val().trim();
		/*if(paramKey=="VAA02"){
			var url = rootUrl + "/clidoctor/selecthuiyuanbingren";
			var para = {
				context:"'%"+mzserach+"%'",
				pageSize:rownumbr,
				currentPage:page
			};
			$.when($.post(url, para)).done(function(json) {
				if(json.result=="Success"){
					 loadSearchData(json,paramKey);
					 laypage({
			                cont: 'vaa05tablePage',
			                pages: Math.ceil(json.total / rownumbr),
//			                groups: $.rate.groups,
			                curr: page || 1, //当前页
			                jump: function(obj, first){ //触发分页后的回调
			                	if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
			                		getSearchData(paramKey,obj.curr);
			                    }
			                }
			             })
				}
		    })
		}else{*/
			var url = rootUrl + "/clidoctor/selectDataByScriptId1";
			var para = {
					ID:997,
					paramStr:"{'"+paramKey+"':'%"+mzserach+"%'}",
					rows:rownumbr,
					page:page
			};
			$.when($.get(url, para)).done(function(json) {
				if(json.result=="Success"){
					 loadSearchData(json,paramKey);
					 laypage({
			                cont: 'vaa05tablePage',
			                pages: Math.ceil(json.total / rownumbr),
//			                groups: $.rate.groups,
			                curr: page || 1, //当前页
			                jump: function(obj, first){ //触发分页后的回调
			                	if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
			                		getSearchData(paramKey,obj.curr);
			                    }
			                }
			             })
				}
		    })
//		}


}
  function loadSearchData(data,paramKey){

		jQuery('#vaa05table').GridUnload();
		 jQuery("#vaa05table").jqGrid(
		          {
		        	data: data.rows,
		 	        datatype: "local",
	                height : "100%",
	                width : "100%",
		            colNames:['姓名','年龄','性别','门诊号','身份证号','手机号','会员卡号',"",""],
		            colModel:[ //这一项比较重要， 其中的name属性主要是用于后期的页面代码（注意这里的范围是本页面上的代码，不会涉及到后台代码）， 而index属性是则是用于涉及后台时，给后台传递排序字段
		                     {name:'vaa05',index:'vaa05',width:"80"},
		                     {name:'vaa10',index:'vaa10',width:"50"},
		                    {name:'abw01',index:'abw01',width:"50",editable:true,formatter:
			                	   function(v,x,r){
			                	   if(v==1){
			                		   return "男";
			                   	   }else{
			                   		  return "女";
			                   	   }
		                	   }
		                   },
		                   {name:'vaa03',index:'vaa03',width:"100"},
		                   {name:'vaa15',index:'vaa15',align:'center',width:"210"},
		                   {name:'vaa35',index:'vaa35',align:'center',width:"130"},
		                   {name:'vaa02',index:'vaa02',align:'center',width:"130"},
		                   {name:'vaa18',index:'vaa18',hidden:true},
		                   {name:'vaa19',index:'vaa19',hidden:true}
		                    ],
		                    rowNum:rownumbr,
		                    jsonReader: {
		                        page:"page",
		                        total:"total",
		                        records:"records",
		                        rows:"rows"
		                     },
		                   multiselect: false, //是否支持多选
		                   rownumbers:true,
		                   forceFit:true,
	 	                   shrinkToFit:true,
	 	                   autowidth:true,
		                   onSelectRow:function(rowid,status) {
//		                	   setsearchvalue(data.rows[rowid-1]);
		                   }, loadComplete : function(data){
		                	   $("#vaa05table").jqGrid("setSelection", 1);
		                   },
		                   ondblClickRow : function(rowid, status)
				            {
		                	   setsearchvalue(data.rows[rowid-1]);
		                	   //聚焦元素
		                	   $(".all_content").find(".key_control_div:visible").eq(0).find(".keycontrol").focus();
				            },
				        	loadComplete : function(data)
					    	{
				        		$("#vaa19").removeAttr("disabled");
					    	}
		          })
}
  function setsearchvalue(thisobj){
	  debugger;
		if (memberSettingData['103005_100_254'] == '1')
		{
			if (thisobj.bck01a)
			{
				$("#vac06_1").iCheck("check");
				$("#vac06").val(1);
			}
			else
			{
				$("#vac06_2").iCheck("check");
				$("#vac06").val(0);
			}
		}
		$('#gh_vaa05').val(thisobj.vaa05?(thisobj.vaa05).trim():'');
//		$("#vaa10").val(thisobj.vaa10?thisobj.vaa10:"");
		if(thisobj.abw01){
			$("#abw01").val(thisobj.abw01).trigger("change");
			
		}else{
			$("#abw01").val(0).trigger("change");
			
		}
		
		debugger;
		$("#gh_vaa01").val(thisobj.vaa01);
		if(thisobj.vaa03){
			$("#vaa03").val(thisobj.vaa03);
			$("#vaa03_1").val(thisobj.vaa03);
			
		}else{
			getvaa03();//重新获取门诊号
		}
		$('#vaa15').val(thisobj.vaa15?thisobj.vaa15:"");
		$('#vaa35').val(thisobj.vaa35?thisobj.vaa35:"");
		//$('#bep06b').val(thisobj.bep06b==null ? 0 : thisobj.bep06b);
		$('#vac57').val(thisobj.vac57==undefined ? "" : thisobj.vac57);
		$('#vac46').val(thisobj.vac46==undefined ? "" : thisobj.vac46);
		$('#vac19').val(thisobj.vaa33==undefined ? "" : thisobj.vaa33);
		$('#ack01').val(thisobj.ack01?thisobj.ack01:"");
		$('#bdp02').val(thisobj.bdp02==null ? thisobj.bdp02a: thisobj.bdp02).trigger("change");
		if (thisobj.bcb01a)
		{
			$('#bcb01').val(thisobj.bcb01a);
		}
		if(thisobj.vaa19){ //险种名称
			$("#vaa19").val(thisobj.vaa19).trigger("change");
			$("#vaa19").attr("disabled",true);
		}else{
			$("#vaa19").val(null).trigger("change");
		}
		if(thisobj.vac16){

			$('#vac16').val(thisobj.vac16).trigger("change");
		}
		$("#vaa18").val(thisobj.vaa18?thisobj.vaa18:"");
		$("#vaa17").val(thisobj.vaa17?thisobj.vaa17:"");
//		$('#bce03').val((thisobj.bce03a==undefined || thisobj.bce03a==null) ? "" : thisobj.bce03a);
		$('#gh_abc02').val(thisobj.abc02==undefined ? "" : thisobj.abc02);
//		 $('#bck03').val((thisobj.bck03==undefined || thisobj.bck03==null) ? "" : thisobj.bck03);
//		 $('#bck01').val((thisobj.bck01a==undefined || thisobj.bck01a==null) ? 0 : thisobj.bck01a);
//	     $('#bce01').val((thisobj.bce01a==undefined || thisobj.bce01a==null) ? 0 : thisobj.bce01a);
	     $('#aau01').val(thisobj.aau01);
//		$('#bcb03').val((thisobj.bcb03==undefined  || thisobj.bcb03==null) ? "" : thisobj.bcb03);
		var vaa12Value=thisobj.vaa12;
//		$('#vbu01').val(thisobj.vbu01);
		$('#vaa02').val((thisobj.vaa02==undefined ||  thisobj.vaa02==null) ? "" : thisobj.vaa02);
		$('#vbu14').val((thisobj.vbu14==undefined ||  thisobj.vbu14==null) ? 0: thisobj.vbu14);
//		$('#vbu15').val((thisobj.vbu15==undefined ||  thisobj.vbu15==null) ? 0: thisobj.vbu15);
//		$('#vbu30').val((thisobj.vbu30==undefined ||  thisobj.vbu30==null) ? 0 : thisobj.vbu30);
		if(thisobj.vaa12 != undefined){
			 $('#vaa12').val(moment(vaa12Value).format("YYYY-MM-DD HH:mm:ss"));
		}else {
			 $('#vaa12').val(moment(new Date()).format("YYYY-MM-DD HH:mm:ss"));
		}
		handsOn("vaa10","vaa12","aau01");
		selectbcb01=thisobj.bcb01a==undefined ? 0 : thisobj.bcb01a;
		if(thisobj.bcb01a){
			gridxiangmu(thisobj.bcb01a,thisobj.vac31);
		}
		//loadbckdata(selectbcb01);
		//loadbcedata(selectbcb01);
	    $('#vaa05html').slideUp().find("tbody tr").remove();
	    $("#layercover").addClass("hidden");
	    //赋值成功之后，根据权限控制病人基本信息是否可以编辑
	    if($.inArray("jygh_brxx",authorityArr)>=0){ 
	    	disableEditPatientInfo();
	    }else{
	    	enableEditPatientInfo();
	    }
	}
  /****************************************************************************************************/
  
function  disableEditPatientInfo(){
	$("#saveGuahao  .ifEditItem").each(function(e,ele){
		$(ele).attr("disabled",true);
	})
}
function  enableEditPatientInfo(){
	$("#saveGuahao  .ifEditItem").each(function(e,ele){
		$(ele).removeAttr("disabled");
	})
}

function hideAllDiv(){
	$("#layercover").on("click",function(){
		$("#layercover").addClass("hidden");
		$('.selectTab').slideUp();

	})
}
//获取住址
function addabu19() {
	$("#vac19").on('click',function(){
		var selectleft=$(this).parent().position().left;
		var selecttop=$(this).parent().position().top;
		$.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:598,paramStr:'{LVLNR:3}'}, function(json){
			if(json.result=="Success"){
				//$('#abu09html table').css("width","100%");
				$("#layercover").removeClass("hidden");
				$("#abu09html").css({left:selectleft+'px',top:selecttop+30+'px'}).slideDown(300);
				$('#abu09html').find("tbody tr").remove();
				var abu09td = "";
				   for(var i=0;i<json.rows.length;i++){
					    var province=json.rows[i].province;
					    if(province==undefined) province="";
					    var area=json.rows[i].area;
					    if(area==undefined) area="";
					    var abu09=json.rows[i].abu09;
					    if(abu09==undefined) abu09="";
					    abu09td +="<tr>"+
						"<td>"+province+"</td>"+
						"<td>"+area+"</td>"+
						"<td>"+abu09+"</td>"+
						"</tr>";
					}
				}
				$('#abu09html tbody').append(abu09td);
				$('#abu09html tbody tr').on('click',function(){
					$("#vac19").val($(this).find("td").eq(2).html());
					$("#vac17").val($(this).find("td").eq(0).html());
					$("#vac18").val($(this).find("td").eq(1).html());
					$("#layercover").addClass("hidden");
					$('#abu09html').slideUp();
					$("#layercover").addClass("hidden");
		    	})
		});

	})
}
//获取工作单位
function loadbaq01(){
	/*$("#baq03").on('click',function(){
		var selectleft=$(this).parent().position().left;
		var selecttop=$(this).parent().position().top;
		$.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:600,paramStr:'{}'}, function(json){
			if(json.result=="Success"){
//				$('#baq01html table').css("width","100%");
				$("#baq01html").css({left:selectleft+'px',top:selecttop+30+'px'}).slideDown(300);
				$('#baq01html').find("tbody tr").remove();
				var baq03td = "";
				   for(var i=0;i<json.rows.length;i++){
					    var baq02=json.rows[i].baq02;
					    if(baq02==undefined) baq02="";
					    var baq03=json.rows[i].baq03;
					    if(baq03==undefined) baq03="";
					    baq03td +="<tr>"+
						"<td>"+baq02+"</td>"+
						"<td>"+baq03+"</td>"+
						"<td hidden='true'>"+json.rows[i].baq08+"</td>"+
						"<td hidden='true'>"+json.rows[i].baq10+"</td>"+
						"<td hidden='true'>"+json.rows[i].baq01+"</td>"+
						"</tr>";
					}
				}
				$('#baq01html tbody').append(baq03td);
				$('#baq01html tbody tr').on('click',function(){
					$("#baq03").val($(this).find("td").eq(1).html());
					$("#baq01").val($(this).find("td").eq(4).html());
					$("#vac26").val($(this).find("td").eq(0).html());
					$("#vac27").val($(this).find("td").eq(1).html());
					$("#vac28").val($(this).find("td").eq(2).html());
					$("#vac29").val($(this).find("td").eq(3).html());
					$("#layercover").addClass("hidden");
					$('#baq01html').slideUp();
					$("#layercover").addClass("hidden");
		    	});
				$("#baq01html").css({left:0,top:30+'px'}).slideDown(300);
		});

	})*/

}
//document.body.onclick = function(event)
//{
//	var e = event || window.event;
//	var elem = e.srcElement || e.target;
//	while (elem)
//	{
//		if ( $(elem).parents().hasClass("selectTab")||$(elem).parents(".input-group").length>0)
//		{
//			return;
//		}
//		elem = elem.parentNode;
//	}
//	$(".selectTab").slideUp(200)
//
//}





    /*------------------------------------------------------检索-------------------------------------------------------*/
// =========================================================页面设置====================================================
function setGuahao(that)
{
	$(that).attr("disabled",true);
	laytplUrl(myurl + "/module/menzhen_set_guahao.html",
	{}, function(data, html)
	{
		var index = layer.open(
		{
		type : 1,
		// scrollbar : false,
		title : "界面设置",
		area :
		["40%", "80%"],
		shade : 0.1,
		// maxmin : true,
		content : html,
		closeBtn : 1,
		success : function()
		{
			$("select").select2(
			{
				language : "zh-CN"
			})
			$(that).removeAttr("disabled");
			$(".remove").on("click", function()
			{
				layer.close(index);
			});

			Inityemianshezhi();

		}
		})

	});
}

// 查询挂号号类的信息
function Inityemianshezhi()
{
	$('#jichu_set_container').resize(function()
	{
		$("#jichu_set_table").setGridWidth($("#jichu_set_container").width() * 1);
	});
	jQuery("#jichu_set_table")
			.jqGrid(
			{
			url : rootUrl + "/clidoctor/selectDataByScriptId",
			postData :
			{
			ID : 7263,
			paramStr : "{}"
			},
			datatype : "json",
			colModel :
			[
			{
			label : "页面元素",
			name : 'description',
			index : 'description',
			editable : true,
			align : 'center'
			},
			{
				label : "显示",
				name : 'saveselected',
				index : 'saveselected',
				editable : true,
				hidden : true,
				align : 'center'
			},


			{
				label : "允许编辑",
				name : 'savecanedit',
				index : 'savecanedit',
				align : 'center',
				editable : true,
				formatter : function(value, row, index)
				{
					if(value == 1){
// 	      			    return "<input  class='magic-checkbox' type='checkbox' id='savecanedit"+row.rowId+"' checked='checked'/><span></span>";
 	      			    return "<input  type='checkbox' id='savecanedit"+row.rowId+"' checked='checked'/>";
 	             	 }else {
// 	             		 return "<input  class='magic-checkbox' type='checkbox' id='savecanedit"+row.rowId+"'/><span></span>";
 	             		 return "<input  type='checkbox' id='savecanedit"+row.rowId+"'/>";
 	             	 }
				}
				},
				{
					label : "必输项",
					name : 'savemustinput',
					index : 'savemustinput',
					align : 'center',
					editable : true,
					formatter : function(value, row, index)
					{
						if(value == 1){
//			      			    return "<input class='magic-checkbox' type='checkbox' id='savemustinput"+row.rowId+"' checked='checked'/><span></span>";
			      			    return "<input  type='checkbox' id='savemustinput"+row.rowId+"' checked='checked'/>";
			             	 }else {
//			             		 return "<input class='magic-checkbox' type='checkbox' id='savemustinput"+row.rowId+"'/><span></span>";
			             		 return "<input type='checkbox' id='savemustinput"+row.rowId+"'/>";
			             	 }
					}
					},
			{
			label : "productid",
			name : 'productid',
			index : 'productid',
			align : 'center',
			hidden : true
			},
			{
			label : "programid",
			name : 'programid',
			index : 'programid',
			align : 'center',
			hidden : true
			},
			{
			label : "paramno",
			name : 'paramno',
			index : 'paramno',
			align : 'center',
			hidden : true
			},
			{
			label : "name",
			name : 'name',
			index : 'name',
			align : 'center',
			hidden : true
			},
			{
			label : "privilege",
			name : 'privilege',
			index : 'privilege',
			align : 'center',
			hidden : true
			},
			{
			label : "pvalue",
			name : 'pvalue',
			index : 'pvalue',
			align : 'center',
			hidden : true
			},
			{
			label : "savecanedit1",
			name : 'savecanedit',
			index : 'savecanedit1',
			align : 'center',
			hidden : true
			},
			{
			label : "savemustinput1",
			name : 'savemustinput',
			index : 'savemustinput',
			align : 'center',
			hidden : true
			}],
			multiselect : true, // 是否支持多选
//			multiboxonly : true,
			rownumbers : true,
			rowNum : 300,
			forceFit : true,
			shrinkToFit : true,
			autowidth : true,
			height : 'auto',
			width:'auto',
//			afterInsertRow: function(rowid, rowData, rowelem) {
//                var mustinput= rowData['savemustinput'];
//                if(mustinput=='1'){
//                    $(rowelem).trigger("onSelectRow");
//                }
//            },
			gridComplete : function()
			{
				var rowIds = jQuery("#jichu_set_table").jqGrid('getDataIDs');
				for (var k = 0; k < rowIds.length; k++)
				{
					var curRowData = jQuery("#jichu_set_table").jqGrid('getRowData', rowIds[k]);
					var curChk = $("#" + rowIds[k] + "").find(".cbox");
					curChk.attr('name', 'checkboxname'); // 给每一个checkbox赋名字
					curChk.attr('value', curRowData['saveselected']); // 给checkbox赋值
					curChk.attr('title', curRowData['description']); // 给checkbox赋予额外的属性值
					if (curRowData['saveselected'] == 1)
					{
						curChk.attr('checked', 'true'); // 设置所有checkbox被选中}
						jQuery("#jichu_set_table").jqGrid('setRowData', rowIds[k],
						{
							saveselected : 1
						});
					}
					else
					{
						curChk.removeAttr('checked'); // 设置所有checkbox被选中}
						jQuery("#jichu_set_table").jqGrid('setRowData', rowIds[k],
						{
							saveselected : 0
						});
					}
				}

			},
			onSelectRow : function(rowid, status)
			{
				var rowDatas = $("#jichu_set_table").jqGrid('getRowData', rowid);
				if ($("#jichu_set_table").find("input[id='jqg_jichu_set_table_" + rowid + "']")[0].checked)
				{
					jQuery("#jichu_set_table").jqGrid('setRowData', rowid,
					{
						saveselected : 1
					});
				}
				else
				{
					if (rowDatas['description'] == "检索" || rowDatas['description'] == "类别" || rowDatas['description'] == "科室" || rowDatas['description'] == "医生" || rowDatas['description'] == "门诊号" || rowDatas['description'] == "身份证号" || rowDatas['description'] == "姓名" || rowDatas['description'] == "姓别" || rowDatas['description'] == "年龄" || rowDatas['description'] == "出生日期" || rowDatas['description'] == "病人类别" || rowDatas['description'] == "费别" || rowDatas['description'] == "移动电话" || rowDatas['description'] == "急诊" || rowDatas['description'] == "复诊" || rowDatas['description'] == "性别")
					{
						$("#jichu_set_table").find("input[id='jqg_jichu_set_table_" + rowid + "']")[0].disabled = true;
						$("#jichu_set_table").find("input[id='jqg_jichu_set_table_" + rowid + "']")[0].checked = true;

						jQuery("#jichu_set_table").jqGrid('setRowData', rowid,
						{
							saveselected : 0
						});

					}
					else
					{
						jQuery("#jichu_set_table").jqGrid('setRowData', rowid,
						{
							saveselected : 0
						});
					}

				}
			},
			onSelectAll : function(rowid, status)
			{ // rowid 数组
				var ids = jQuery("#jichu_set_table").jqGrid('getDataIDs');
				if (!$("#cb_jichu_set_table")[0].checked)
				{
					for (var i = 0; i < ids.length; i++)
					{
						var cl = ids[i];
						var curRowData = jQuery("#jichu_set_table").jqGrid('getRowData', cl);
						if (curRowData['description'] == "检索" || curRowData['description'] == "类别" || curRowData['description'] == "科室" || curRowData['description'] == "医生" || curRowData['description'] == "门诊号" || curRowData['description'] == "身份证号" || curRowData['description'] == "姓名" || curRowData['description'] == "姓别" || curRowData['description'] == "年龄" || curRowData['description'] == "出生日期" || curRowData['description'] == "病人类别" || curRowData['description'] == "费别" || curRowData['description'] == "移动电话" || curRowData['description'] == "急诊" || curRowData['description'] == "复诊" || curRowData['description'] == "性别")
						{
							$("#jichu_set_table").find("input[id='jqg_jichu_set_table_" + cl + "']")[0].checked = true;
							$("#jichu_set_table").find("input[id='jqg_jichu_set_table_" + cl + "']")[0].disabled = true;
							jQuery("#jichu_set_table").jqGrid('setRowData', cl,
							{
								saveselected : 1
							});

						}
						else
						{
							jQuery("#jichu_set_table").jqGrid('setRowData', cl,
							{
								saveselected : 0
							});
						}
					}
				}
				else
				{
					for (var j = 0; j < ids.length; j++)
					{
						var clj = ids[j];
						var curRowData = jQuery("#jichu_set_table").jqGrid('getRowData', clj);
						jQuery("#jichu_set_table").jqGrid('setRowData', clj,
						{
							saveselected : 1
						});
					}
				}
			},
			loadComplete : function(data)
			{
				debugger;
				if (data.length < 1) {
					var $tr = $('#jichu_set_table').find('tbody>tr:last');
					var len = $tr.find('td').length;
					$("#jichu_set_table").html('<tr><td colspan="'+ parseInt(len)+ '" style="text-align:left;">没有符合条件的数据！</td></tr>');
				}
			}

			});
}
// 校验选中或者是没选中的值
function changesavecanedit(obj, r)
{
	var rows = jQuery("#jichu_set_table").jqGrid('getDataIDs');
	if (obj.checked)
	{
		jQuery("#jichu_set_table").jqGrid('setRowData', r,
		{
			savecanedit : 1
		});
	}
	else
	{
		jQuery("#jichu_set_table").jqGrid('setRowData', r,
		{
			savecanedit : 0
		});
	}
}
function changesavemustinput(obj, r)
{
	debugger;
	var rows = jQuery("#jichu_set_table").jqGrid('getDataIDs');
	if (obj.checked)
	{
		jQuery("#jichu_set_table").jqGrid('setRowData', r,
		{
			savemustinput : 1
		});
	}
	else
	{
		jQuery("#jichu_set_table").jqGrid('setRowData', r,
		{
			savemustinput : 0
		});
	}
}
// 保存页面设置的信息
function savePageInfo()
{
	var index = layer.msg('设置中....',{icon : 16,skin: 'layui-layer-msg16',shade :[0.1, '#393D49'],time : 0});
	var ids = jQuery("#jichu_set_table").jqGrid('getDataIDs');
	for (var j = 0; j < ids.length; j++)
	{
		var cl = ids[j];
		//允许编辑
 		if($("#jichu_set_table tr[id="+cl+"] td:eq(5)").find('input[id=savecanedit'+cl+']').eq(0).prop('checked')){
 			jQuery("#jichu_set_table").jqGrid('setRowData',cl,{savecanedit:1});
 		}else{
 			jQuery("#jichu_set_table").jqGrid('setRowData',cl,{savecanedit:0});
 		}
 		//必输项判断
 		if($("#jichu_set_table tr[id="+cl+"] td:eq(4)").find('input[id=savemustinput'+cl+']').eq(0).prop('checked')){
 			jQuery("#jichu_set_table").jqGrid('setRowData',cl,{savemustinput:1});
 		} else{
 			jQuery("#jichu_set_table").jqGrid('setRowData',cl,{savemustinput:0});
 		}


		var curRowData = jQuery("#jichu_set_table").jqGrid('getRowData', cl);
		var pvalue = curRowData["saveselected"] + ";" + curRowData["savemustinput"] + ";" + curRowData["savecanedit"];
		jQuery("#jichu_set_table").jqGrid('setRowData', cl,
		{
			pvalue : pvalue
		});
	}
	var rowDatas = $("#jichu_set_table").jqGrid('getRowData');
	var row = JSON.stringify(rowDatas);
	$.ajax(
	{
	type : 'post',
	url :  rootUrl + "/clidoctor/SavedOneUserParameters",
	data :
	{
		'grid2rows' : row
	},
	dataType : "json",
	success : function(data)
	{
		if (data.result == "Success" || data.result == "SUCCESS")
		{
			debugger;
			layer.msg('设置中成功',{icon : 1,skin: 'layui-layer-msg1',shade :[0.1, '#393D49'],time : 2000});
			layer.closeAll();
			setTimeout(function(){
				guahao()
			},200)
		}
	}

	});
	return false;
}


function checkvcj15_1(obj) {
	if ($(obj).attr("id")=="vcj15_1") {
		$("#vcj15").val(1);
	} else {
		$("#vcj15").val(0);
	}
}
//复诊赋值
function checkvac06(obj) {
	if ($(obj).attr("id")=="vac06_1") {
		$("#vac06").val(1);
	} else {
		$("#vac06").val(0);
	}

}
//急诊赋值
function checkvac10(obj) {
	if ($(obj).attr("id")=="vac10_1") {
		$("#vac10").val(1);
	} else {
		$("#vac10").val(0);
	}
}

// 加载修改信息
function loadSysParm()
{
	$.ajax(
			{
			type : 'get',
			url : rootUrl + "/clidoctor/selectDataByScriptId?ID=7263",
			dataType : "json",
			success : function(data)
			{
				if (data.result == "Success" || data.result == "SUCCESS")
				{
					json = eval(data); // 数组
					$(".huiyuanxinxi").addClass("hidden");
					$(".danweixinxi").addClass("hidden");
					$(".crmxinxi").addClass("hidden");
					for (var i = 0; i < json.list.length; i++)
					{
						if (json.list[i].saveselected == 1)
						{
							var infoclass = "info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno;
							$(".info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno).removeClass("hidden");
							// 必填字段在页面的体现
							if (json.list[i].savemustinput == 1)
							{

								$(".info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno).find(".must").removeClass("hidden");
								if ("info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno != "info100103005108" && "info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno != "info100103005107" && "info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno != "info100103005142" && "info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno != "info100103005102" && "info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno != "info100103005114" && "info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno != "info100103005130" && "info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno != "info100103005126")
								{
									$(".info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno)
											.find(".name").next().addClass("validate[required]");
								}

							}
							else
							{
								$(".info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno).find(".must").addClass("hidden");
							}
						}
						else
						{

							$(".info" + json.list[i].productid + json.list[i].programid + json.list[i].paramno)
									.addClass("hidden");
						}

					}
				}
			}
			});
}
//-------------------------------------------------医保卡--------------------------------------------------------------------------------//
//医保卡按钮点击事件,门诊只是读卡
function readcard(){
	debugger;
	 layer.msg('读卡中....', {icon: 16,skin: 'layui-layer-msg16',shade: [0.1, '#393D49'],time:1*500});
	 //清空页面所有input
	 $("#saveGuahao").find("input").val("");
	 $("#bcb03").val(0).trigger("change")
	 var iaa01_d = $("#iaa01").find("option:eq(1)").val()
	 $("#iaa01").val(iaa01_d).trigger("change");
	 $("#iaa01").find("option[value='569']").attr("selected",true).trigger("change");
	 loadiai1();
	var readCardPar="{\"root\":{\"reginfo\":{\"ie\":\"\"}}}";
	var iai03;
	if(!$('#iai01 option:selected').text()){
			iai03=$('#iai01 option:selected').text().substring($('#iai01 option:selected').text().indexOf("(")+1,$('#iai01 option:selected').text().indexOf(")"));
	}
	 var orderStrUrl = hoinsurance+'/onloadform?id=100210&userId='+$.cookie('loginName')+'&iaa01='+$("#iaa01").val()+'&paramstr=' + readCardPar;  //---接口命令调用方法
	    $.ajax({ url: orderStrUrl,
	         dataType: 'jsonp',
	         jsonp: "callback",
	         jsonpCallback: "success_jsonpCallback",
	         success: function (data) {
	        	 if(data["root"] != undefined){
	        		 if(data["root"].result=="Success"){
	        			  $("#yibaocover").addClass('hidden');
	        			 if(memberSettingData['116001_1_79']==1){
	        				 searchShuaPromVal(data["root"]["iar1"]["ie"]["iak05"]);
	        			 }else{
	        				 if(data["root"]["personinfo"]["ie"]["sex"]==1){
	            				 $("#abw01").val("1");
	            			 }else{
	            				 $("#abw01").val("2");
	            			 }
	            			 $("#gh_vaa05").val(data["root"]["personinfo"]["ie"]["ptname"]);
	                		 //年龄
	                		 $("#vaa10").val(data["root"]["personinfo"]["ie"]["age"]);
	                		 //出生日期
	                		 $("#vaa12").val(data["root"]["personinfo"]["ie"]["birthday"]+" 00:00:00");
	                		 //身份证号
	                		 $("#vaa15").val(data["root"]["personinfo"]["ie"]["idnumber"]);
	        			 }


		            		 //保险号
		            		 $("#iak05").val(data["root"]["iar1"]["ie"]["iak05"]);
		            		 //保险卡号
		            		 $("#iak04").val(data["root"]["iar1"]["ie"]["iak04"]);
		            		 //医保金额
		            		 $("#iar33").val(data["root"]["iar1"]["ie"]["iar33"]);
		            		 //单位编码
		            		 $("#iar12").val(data["root"]["iar1"]["ie"]["iar12"]);
	            	 }else{
	            		 if(data["root"].result=="0"){
	            			 layer.alert("未实现刷卡功能", {icon:2,skin:'layui-layer-msg2'});
	                		 $("#yibaocover").addClass('hidden');
	            		 }else{
	            			 layer.alert(data["root"].result, {icon:2,skin:'layui-layer-msg2'});
	                		 $("#yibaocover").addClass('hidden');
	            		 }

	            	 }
	        	 }
	         },
	         error: function (xhr) {
	        	 layer.alert("请检查医保服务是否启动", {icon:2,skin:'layui-layer-msg2'});
	        	 $("#yibaocover").addClass('hidden');
	         }
	     });
}

//检索之后部分select 不能输入或选择，需要重置
function reSetGuahaoHtml(){
	getvaa03(); //新生门诊号
	//医生有新增病人权限
	if($.inArray("jygh_onlysearch",authorityArr) >=0){ 
		disableEditPatientInfo();
    }else{
    	enableEditPatientInfo();
    }
	$("#saveGuahao").find(".allowEmpty").val("");
	$("#saveGuahao").find("#vaa19").val(null).trigger("change");
	$("#saveGuahao").find("#vaa19").removeAttr("disabled");

}
